home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir36 / tsbat46.zip / DOSTRICK.TXT < prev    next >
Text File  |  1994-09-04  |  10KB  |  252 lines

  1. Assorted MsDos Tricks                                 Sun 4-Sep-94
  2. =====================
  3.                                                All rights reserved
  4.                                   Copyright (c) 1994 by Timo Salmi
  5.  
  6. ..................................................................
  7. Prof. Timo Salmi      Co-moderator of comp.archives.msdos.announce
  8. Moderating at garbo.uwasa.fi anonymous FTP  archives  128.214.87.1
  9. Faculty of Accounting & Industrial Management; University of Vaasa
  10. Internet: ts@uwasa.fi   BBS +(358)-61-3170972; FIN-65101,  Finland
  11. ..................................................................
  12.  
  13.   ┌───────────────────────────────────────────────────────────┐
  14.   │ This file belongs to TSBAT*.ZIP. Please do not distribute │
  15.   │ this dostrick.txt file separately!                        │
  16.   └───────────────────────────────────────────────────────────┘
  17.  
  18. You are free to quote brief passages from this file provided you
  19. clearly indicate the source with a proper acknowledgment.
  20.  
  21. Comments and corrections are solicited. But if you wish to have
  22. individual MsDos usage consultation, please rather post your
  23. question to a UseNet newsgroup like comp.os.msdos.misc. It is much
  24. more efficient than asking me by email. I'd like to help, but I am
  25. very pressed for time. I prefer to pick the questions I answer from
  26. the Usenet news. Thus I can answer publicly at one go if I happen to
  27. have an answer. Besides, newsgroups have a number of readers who
  28. might know a better or an alternative answer. Don't be discouraged,
  29. though, if you get a reply like this from me. I am always glad to
  30. hear from fellow MsDos users.
  31.  
  32.  
  33. INDEX
  34. =====
  35.  
  36. 1) Disabling MsDos commands
  37. 2) Simulating disk partitioning
  38. 3) A config.sys and autoexec.bat example
  39. 4) Stepping through config.sys and autoexec.bat command by command
  40. 5) Getting rid of "Insert diskette for drive B:"
  41. 6) Conditional deleting of files
  42. 7) Selected Doskey macro examples
  43.  
  44.  
  45. 1. Disabling MsDos commands
  46. ===========================
  47.  
  48. You may wish to disable certain MsDos commands for security reasons
  49. to prevent them from being used either accidentally or deliberately.
  50. If you have a command line editor, like doskey, then the disabling
  51. is rather straigtforward.  All you have to do is to create a macro
  52. with the same name as the MsDos command. Consider the following
  53. examples. The first example disables the internal MsDos date command
  54. so that the date on your system cannot be changed.
  55.   doskey date=rem date has been disabled
  56. The second example disables the format command.
  57.   doskey format=rem format has been disabled
  58. Note that since format is an external command, that is it is a
  59. program on your disk, not a command in your command.com command
  60. interpreter, you can still invoke it by giving the explicit path to
  61. it like
  62.   c:\dos\format
  63. In fact, since it will be at path, a drive letter will suffice. Of
  64. course it is very easy to ged rid of these redefinitions. In using
  65. doskey, you only have to press alt+F10 to clear the macros.
  66.  
  67. If you use some other command line editor than doskey then the
  68. commands are naturally slightly different.  For example were you to
  69. use CED (garbo.uwasa.fi:/pc/cmdutil/ced10da.zip) the commands would
  70. be
  71.   ced syn date echo date has been disabled
  72. Restoring the date command would be
  73.   ced clear syn date
  74.  
  75.  
  76. 2. Simulating disk partitioning
  77. ===============================
  78.  
  79. Since I have more than one PC at my disposal, I have noticed that it
  80. is very useful to have some common standard on them including
  81. similar disk names. For example I always assume that R: is my
  82. ramdisk. Also I usually have my hard disk partitioned so that I have
  83. a pairly fixed usage for C: D: E: and F:. One of the PCs is an ICL
  84. laptop, with a 120Mb disk all on C: with no partitioning. below is
  85. what I have in my autoexec.bat to have the ram disk reference the
  86. way I want and to simulate the disk partitioning. Note the
  87. importance of the order of the substitute commands because of the
  88. double usage of D, since that is where the ram disk _originally_
  89. resides on my ICL configuration.
  90.   c:\dos\subst r: d:\
  91.   c:\dos\subst d: c:\d
  92.   c:\dos\subst e: c:\e
  93.   c:\dos\subst f: c:\f
  94.  
  95.  
  96. 3. A config.sys and autoexec.bat example
  97. ========================================
  98.  
  99. There always is something to learn from looking at the other users'
  100. config.sys and autoexec.bat files. Here are mine from my office 486
  101. with MsDos 5.0.  I have added some comments for you.
  102.  
  103. DEVICE=C:\DOS\SETVER.EXE
  104. DEVICE=C:\DOS\HIMEM.SYS
  105. DOS=UMB
  106. device=c:\dos\emm386.exe /noems /i=e000-efff /x=d200-d600
  107. dos=high
  108. COUNTRY=032,,C:\DOS\COUNTRY.SYS
  109. FILES=30
  110. devicehigh=c:\dos\ramdrive.sys 7000 128 256 /e
  111. rem ZANSI.SYS is from garbo.uwasa.fi:/pc/screen/zansi12.zip
  112. devicehigh=c:\sys\zansi.sys
  113. rem Define a bigger environment size
  114. shell=c:\command.com /p /e:1024
  115. lastdrive=z
  116.  
  117. @ECHO OFF
  118. rem Description: My normal MsDos 5.0 boot with Scrollit
  119. rem Note below the trick to identify which of my PCs I am using:
  120. set pcid_=karvi
  121. rem Yellow text on black background
  122. echo <ESC>[40;33;1m
  123. PATH C:\DOS;c:\tools;e:\arczip
  124. rem DAILY.EXE is from /pc/ts/tsbat46.bat to run a mini-backup
  125. rem call c:\bat\daily c:\tools\pkzip -u d:\root\root c:\*.*
  126. PROMPT $p$g
  127. rem CHKSUM is from /pc/goldies/chksum16.zip
  128. c:\tools\chksum command.com 49024 io.sys 9850 msdos.sys 5750
  129. loadhigh c:\dos\KEYB SU,,C:\DOS\KEYBOARD.SYS
  130. rem The Command line EDitor is from /pc/goldies/ced.zip
  131. loadhigh c:\tools\ced -B384,128,768,128,128 -Fced.cfg
  132. rem The TSR memory management until is from /pc/memutil/tsrcom35.zip
  133. c:\tools\mark scrollit
  134. rem The screen scrollback buffer is from /pc/screen/scrlit18.zip
  135. loadhigh c:\tools\scrollit /n=myname /k=myid 60
  136. rem The Snipper screen capture is from /pc/goldies/snippr24.zip
  137. loadhigh c:\tools\snipper
  138. rem The cut and paste utility is from /pc/pcmagvol/vol11n07.zip
  139. loadhigh c:\tools\dosclip2
  140. rem The CapsLock fix is from /pc/ts/tstsr20.zip
  141. loadhigh c:\tuki\shftcaps
  142. c:\dos\subst r: j:\
  143. mkdir r:\cmand
  144. copy c:\command.com r:\cmand
  145. c:\dos\attrib +r r:\cmand\command.com
  146. set comspec=r:\cmand\command.com
  147. set temp=r:\cmand
  148. c:\dos\mode con: rate=32 delay=1
  149. rem The clock comparison check is from /pc/ts/tsutil40.zip
  150. c:\tools\dtetimal 1994
  151. r:
  152.  
  153.  
  154. 4. Stepping through config.sys and autoexec.bat command by command
  155. ==================================================================
  156.  
  157. MsDos 6.0 introduced the possibility of pausing at each line of
  158. config.sys and even selecting if the line is executed. If you press
  159. F8 when your PC is being booted and displays "Starting MS-DOS...",
  160. then "MS-DOS will prompt you to confirm each CONFIG.SYS command". If
  161. you have an earlier MsDos version, you can still put pauses in your
  162. config.sys by utilizing
  163.  6333 Jan 23 1993 garbo.uwasa.fi:/pc/sysutil/pausedev.zip
  164.  pausedev.zip PAUSE for config.sys (with TP source) D.Murdoch
  165.  
  166. To step through autoexec.bat you can use the following trick
  167.   @echo off
  168.   set debug_=true
  169.   command1
  170.   if "%debug_%" == "true" pause
  171.   command2
  172.   if "%debug_%" == "true" pause
  173.   command3
  174.   set debug_=
  175.  
  176. If you have MsDos 6.0 or later you can use the CHOICE command to
  177. prompt whether you want a command to be executed. If you have an
  178. earlier MsDos version you can use "CHOOSE.EXE Ask questions in batch
  179. files" from the garbo.uwasa.fi:/pc/ts/tsutlf14.zip (or ASK.EXE from
  180. /pc/ts/tsbat46.zip). Below is an outline example
  181.  
  182.   @echo off
  183.   set debug_=true
  184.  
  185.   if not "%debug_%" == "true" goto _comm1
  186.   CHOOSE /c:yn /n "Execute command1 [Y/N]? "
  187.   if not errorlevel==3 if errorlevel==2 goto _next2
  188.   :_comm1
  189.   command1
  190.  
  191.   :_next2
  192.   if not "%debug_%" == "true" goto _comm2
  193.   CHOOSE /c:yn /n "Execute command2 [Y/N]? "
  194.   if not errorlevel==3 if errorlevel==2 goto _next3
  195.   :_comm2
  196.   command2
  197.  
  198.   :_next3
  199.   (and so on)
  200.  
  201.   set debug_=
  202.  
  203.  
  204. 5. Getting rid of "Insert diskette for drive B:"
  205. ================================================
  206.  
  207.  Q: On my one-floppy-drive PC how can I get rif of the message
  208. "Insert diskette for drive B: and press any key when ready"?
  209.  
  210.  A: The answer is simple as can be. Put the following command into
  211. your AUTOEXEC.BAT file: "SUBST B: A:\". It makes B: point to the one
  212. floppy drive (A:) you have on your system.
  213.  
  214.  
  215. 6. Conditional deleting of files
  216. ================================
  217.  
  218.  This is an improved adaptation of the tip in the PC Computing
  219. Special Issue, 1001 tips, August 1994, pp. 106-232.
  220.  If you have MsDos 5+ you can utilize this simple doskey macro to
  221. move files to a trash directory. First ensure that such a directory
  222. exists and if not, mkdir it.
  223.   doskey del=if exist $1 copy $1 r:\trash$Tif not exist $1 echo
  224.   File $1 not found^G$Tif exist $1 del $1 /p
  225. where all the above is on the SAME line.
  226.  You can precede the command with loadhigh to save conventional
  227. memory. I have r: as ramdisk so the trash directory will
  228. automatically be erased when I turn off the computer, or when it
  229. chooses to crash :-).
  230.  
  231.  
  232. 7. Selected Doskey macro examples
  233. =================================
  234.  
  235. These examples are given without explanations. They are reasonably
  236. simple and besides you'll learn working them out yourself. Be
  237. slightly careful in experimenting. Make test files to try then on
  238. rather than running them on your existing files.
  239.  
  240.  doskey up=if exist ..\nul cd ..
  241.  
  242.  doskey mv=if exist $2\nul copy $1 $2$Tif exist $2\nul del $1 /p
  243.  
  244.  doskey format=echo Bugger off^G^G^G
  245.  (Tip: to format, give the full path. Usually c:\dos\format)
  246.  
  247.  doskey touch=copy $1 + ,,$Tdir $1
  248.  
  249.  doskey where=for %f in (c d e f g h) do dir %f:\$1 /s /p /b
  250.  
  251.  doskey showtime=echo.$Btime$Techo.$Bdate
  252.